const express=require("express")
const app=express()
const url=require("url")
const bodyParser=require("body-parser")

app.use(bodyParser.urlencoded({
    extended:true
}))


// 接受参数 user=? get发送的信息可以放在页面上渲染
app.get("/list",(req,res)=>{
    const user=url.parse(req.url,true).query.user
    console.log(user,'--user');//kun --user
    
    if(user==='kun'){
        res.send({
            msg:user
        })
    }else{
        res.send({
            msg:"测试"
        })
    }
})

app.post("/login",(req,res)=>{
    const username=req.body.username
    const password=req.body.password
    if(username==='kunkun'&&password=="123456"){
        res.send({
            msg:"登陆成功"
        })
    }else{
        res.send({
            msg:"登陆失败"
        })
    }
})

app.listen(3000,()=>{
    console.log('server run');
    
})